package day11;


import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Demo {
    public static void main(String[] args) throws ParseException {
        Date d = new Date();
        System.out.println(d);
        double de = 2.5678;
        //2.日期格式化
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss ms a");
        System.out.println(sdf.format(d));

        DecimalFormat df = new DecimalFormat("0.00");
        System.out.println(df.format(de));

        //Date==>String
        String result = sdf.format(d);
        System.out.println(result);

        Date time = sdf.parse("2014/12/20 20:12:54 60 上午");
        System.out.println(time);

        Date d2 = new Date();
        long ms = d2.getTime();
        long ms2 = System.currentTimeMillis();
        System.out.println("毫秒数:"+ms);
        System.out.println("毫秒数2:"+ms2);

        Date d3 = new Date();
        java.sql.Date sqlDate = new java.sql.Date(d3.getTime());
        System.out.println(d3);
        System.out.println(sqlDate);

        Date d4 = new Date(sqlDate.getTime());
        System.out.println(d4);
    }
}
